<template>
	<view class="page">
		<!-- 列表 -->
		<view class="prescript-list">
			<LoadMore ref="LoadMore" id="LoadMore" :diffHeight="152" :initData="initData" @dataRefresh='dataRefresh' @infoRefresh='infoRefresh'>
				<block v-for="(pitem, pindex) in dataList" :key="pindex">
					<view class="card">
						<view class="personal font14">就诊人：{{pitem.user_the_patient_info.name}}<text>{{pitem.user_the_patient_info.sex == '1' ? '男' : '女'}}</text><text>{{pitem.user_the_patient_info.birthday}}岁</text></view>
						<view class="item" @click="goDetail(item.id)" v-for="(item, index) in pitem.prescription_list" :key="index">
							<view class="part1 flex-row-between">
								<view class="font14">{{item.name||''}}</view>
								<view class="font12 font-969696">共{{item.goods_count}}种药品</view>
							</view>
							<view class="part2">
								<view class="name font14">临床诊断：{{item.diagnosis_proposal || item.diagnose}}</view>
								<!-- 此处最多展示2个药品 -->
								<block v-for="(drug, i) in item.goods_list" :key="i">
									<view v-if="i < 2" class="font12 font-969696">
										<text>{{drug.goods_name}} {{drug.spec_name}} *{{drug.number}}</text>
										<text v-if="i == 1">...</text>
									</view>
								</block>
							</view>
							<uni-icons class="icon" type="arrowright" size="14" color="#969696"></uni-icons>
						</view>
					</view>
				</block>
			</LoadMore>
		</view>
	</view>
</template>

<script>
	import LoadMore from "@/components/loadMore.vue";
	import topBar from "@/components/ComTopBar.vue";
	export default {
		components: { LoadMore, topBar },
		data() {
			return {
				//传参数据
				initData: {
					url: 'listSendPrescription',
					param: {},
				},
				dataList:[],
			}
		},
		onLoad(options){
			if(options.funnel) this.initData.param.funnel = options.funnel
		},
		methods: {
			// loadmore返回数据
			dataRefresh(e) {
				let $this = this
				e.forEach(item => {
					if (item.user_the_patient_info) {
						item.user_the_patient_info.birthday = $this.$base.Onage(item.user_the_patient_info.birthday)
					}
				})
				this.dataList = e
			},
			// loadmore返回信息
			infoRefresh(e) {
				this.count = e.count
			},
			// 处方详情
			goDetail (prescriptId) {
				uni.navigateTo({
					url: '/pagesA/prescript/doctorOrderDetail?id=' + prescriptId
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("style.less");
	
	/deep/.u-navbar__content__right__text{
		color: #006EFF;
	}
	
	page{
		padding-bottom: 0;
	}
	.prescript-list{
		padding: 0 20rpx;
		
		.item{
			width: 100%;
			padding-bottom: 0;
		}
		
		.personal{
			text{
				color: #969696;
				font-size: 12px;
				padding-left: 15px;
			}
		}
	}
	.card{
		border-radius: 10rpx;
		background-color: #f6f6f6;
		margin-bottom: 20rpx;
		padding: 20rpx;
	}
	
</style>
